${light}

${material}

${fog}

uniform float speed;
uniform int selector;
uniform vec3 cameraPosition;
uniform ece_LightSource light[MaxLightCount];
uniform ece_Material material;
uniform ece_Fog fog;
uniform sampler2D noise;
uniform samplerCube skybox;
varying vec2 vTexCoord;
varying vec3 vPosition;
varying float vDistance;
varying vec3 vTangentViewPos;
varying vec3 vTangentFragPos;
void main() {
	vec3 normal = normalize(texture2D(noise, vec2(vTexCoord.x + speed, vTexCoord.y)).rbg  * 2.0 - 1.0);
	
	//反射
	vec3 I =  normalize(vPosition - cameraPosition);
	vec3 R = reflect(I, normal);
	
	//float ratio = 1.00 / 1.52;
    //vec3 ZI = normalize(vPosition - cameraPosition);
    //vec3 ZR = refract(I, normal, ratio);
    
	vec4 baseColor = textureCube(skybox, R);
	
	vec3 viewDir = normalize(vTangentViewPos - vTangentFragPos);
	float shininess = material.enable ? material.shininess : 24.0;
	
	vec3 ambient = vec3(0);
	vec3 diffuse = vec3(0);
	vec3 specular = vec3(0);
	
	LightPixel(light, vTangentFragPos, normal, viewDir, shininess, ambient, diffuse, specular);
	
	vec3 color = vec3(0.0);
	MaterialMix(material, ambient, diffuse, specular, baseColor.rgb, color);
    FogMix(fog, vDistance, color);
    if(selector == 1) {
    	color = mix(color, vec3(0.8, 0, 0), 0.2);
    } else if(selector == 2) {
    	color = mix(color, vec3(1.0, 1.0, 1.0), 0.3);
    }
	gl_FragColor = vec4(color, 0.6);
}